﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using XNADota.MDX;
using Microsoft.Xna.Framework;

namespace XNADota.Graphics
{
    #region base class
    public class PaletteRenderer
    {
        public PaletteRenderer()
        {
            _ReferenceSet = new List<PaletteReference>();
        }

        private List<PaletteReference> _ReferenceSet;

        public List<PaletteReference> ReferenceSet
        {
            get { return _ReferenceSet; }
            set { _ReferenceSet = value; }
        }

        public virtual void Begin() {}
        public virtual void End() {}
    }
    #endregion

    #region 2D Graphics
    public class SpriteRenderer : PaletteRenderer
    {
        private SpriteBatch _SpriteBatch;

        public SpriteBatch SpriteBatch
        {
            get { return _SpriteBatch; }
        }
        public SpriteRenderer(SpriteBatch spriteBatch)
        {
            _SpriteBatch = spriteBatch;
        }

        public override void Begin()
        {
            _SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
        }

        public override void End()
        {
            _SpriteBatch.End();
        }
    }
    #endregion


    #region 3D Graphics
    public class CliffRenderer : ModelRenderer
    {
        public CliffRenderer(GraphicsDevice graphicsDevice, MDX.Model Model)
            : base(graphicsDevice, Model)
        {
        }

        public void UpdateCliff(Vector3[] Positions, bool IsCliffTrans, EDirection direction, ESide side, Matrix World)
        {
            foreach (GeosetRenderer GeosetRenderer in _GeosetRenderers)
            {
                GeosetRenderer.UpdateCliff(Positions, IsCliffTrans, direction, side, World);
            }
        }

        public CliffRenderer Copy()
        {
            return new CliffRenderer(this._GraphicsDevice, this._Model);
        }
    }

    public class DoodadRenderer : MDX.ModelRenderer
    {
        public DoodadRenderer(GraphicsDevice graphicsDevice, MDX.Model Model)
            : base(graphicsDevice, Model)
        {
        }
    }

    public class UnitRenderer : DoodadRenderer
    {
        public UnitRenderer(GraphicsDevice graphicsDevice, MDX.Model Model)
            : base(graphicsDevice, Model)
        {
        }
    }
    #endregion

}
